﻿<phone:PhoneApplicationPage 
    x:Class="Leuphana.GuidedTour.App.Pages.TourPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    d:DataContext="{d:DesignData /SampleData/TourViewModelSampleData.xaml, Instance={x:Null}}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--Resources-->
    <phone:PhoneApplicationPage.Resources>
        <CollectionViewSource x:Key="HotSpotList" Source="{Binding HotSpots}"  />
        <CollectionViewSource x:Key="HighlightList" Source="{Binding HotSpots}" Filter="CollectionViewSource_Filter_Highlights" />

        <DataTemplate x:Key="HotSpotViewModelTemplate">
            <Button Style="{StaticResource ChromelessButtonStyle}" Margin="12,0,0,12"
                    Command="{Binding NavigateToCommand}" CommandParameter="{Binding ID}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="50"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Path Data="M0.5,0.5 L61.5,0.5 L61.5,52 L0.5,98.5 z" Fill="{StaticResource PhoneAccentBrush}" HorizontalAlignment="Left" Height="95" Stretch="Fill" VerticalAlignment="Top" Width="50" UseLayoutRounding="False" Margin="0,12,0,0"/>
                    <TextBlock Text="{Binding ID}" FontFamily="Segoe WP Semibold" Foreground="White" Width="50" TextAlignment="Center" Height="50" VerticalAlignment="Top" Margin="0,24,0,0"/>
                    <StackPanel Grid.Column="1">
                        <TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextLargeStyle}"/>
                        <TextBlock Text="{Binding Description}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
                    </StackPanel>
                </Grid>
            </Button>
        </DataTemplate>
        <DataTemplate x:Key="HighlightViewModelTemplate">
            <Button Style="{StaticResource ChromelessButtonStyle}" Margin="12,0,0,12"
                    Command="{Binding NavigateToCommand}" CommandParameter="{Binding ID}">
                <Border Background="{StaticResource PhoneAccentBrush}">
                    <Grid Height="173" Width="173">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="2*"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.Background>
                            <ImageBrush ImageSource="{Binding ImageSource}" />
                        </Grid.Background>
                    
                        <StackPanel Grid.Row="2" Background="#80000000">
                            <TextBlock Text="{Binding Title}" Foreground="White" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
                        </StackPanel>
                    </Grid>
                </Border>
            </Button>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="56"/>
            <RowDefinition Height="221"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <!--TitlePanel-->
        <StackPanel Margin="12,17,0,0">
            <TextBlock Text="APP TITLE" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>

        <!--Map-->
        <maps:Map x:Name="Map" VerticalAlignment="Top" Grid.Row="1" LogoVisibility="Collapsed" CopyrightVisibility="Collapsed"
                  CredentialsProvider="add your bing maps id"
                  Loaded="Map_Loaded">
            <maps:MapItemsControl ItemsSource="{Binding HotSpots}">
                <maps:MapItemsControl.ItemTemplate>
                    <DataTemplate>
                        <maps:Pushpin Location="{Binding Location}" Content="{Binding ID}" />
                    </DataTemplate>
                </maps:MapItemsControl.ItemTemplate>
            </maps:MapItemsControl>
            <maps:Pushpin x:Name="LocationPin" Content="Standort" Background="{StaticResource PhoneAccentBrush}" Visibility="Collapsed" />
        </maps:Map>

        <!--Pivotcontrol-->
        <controls:Pivot x:Name="ContentItems" Title="" Grid.Row="2" Margin="0,-24,0,0">

            <!--Tourlist-->
            <controls:PivotItem Header="Tour">
                <Grid>
                    <ListBox ItemsSource="{Binding HotSpots}" ItemTemplate="{StaticResource HotSpotViewModelTemplate}"/>
                </Grid>
            </controls:PivotItem>

            <!--Highlights-->
            <controls:PivotItem Header="Highlights">
                <Grid>
                    <ListBox ItemsSource="{Binding Highlights}" ItemTemplate="{StaticResource HighlightViewModelTemplate}">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <toolkit:WrapPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>

    <!--Applicationbar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton Click="AppBar_Position_Click" Text="Meine Position" IconUri="/Toolkit.Content/appbar.location.circle.png" />
            <shell:ApplicationBarIconButton Click="AppBar_Heuckenlock_Click" Text="Heucken-lock" IconUri="/Toolkit.Content/appbar.location.png" />
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>